<template>
  <app-navbar />
  <div class="game-merch-layout">
    <side-bar v-if="isLoggedIn" />
    <div class="game-merch-view">
      <h2>游戏周边商城</h2>
      <div class="merch-list">
        <div v-for="item in merchs" :key="item.id" class="merch-card">
          <img :src="item.img" class="merch-cover" />
          <div class="merch-info">
            <h3>{{ item.title }}</h3>
            <div class="merch-meta">
              <span class="merch-type">{{ item.type }}</span>
              <span class="merch-price">￥{{ item.price }}</span>
              <span :class="['merch-status', item.inStock ? 'in-stock' : 'out-stock']">
                {{ item.inStock ? '有货' : '无货' }}
              </span>
            </div>
            <div class="merch-actions">
              <button v-if="item.inStock" class="buy-btn">购买</button>
              <button class="detail-btn">详情</button>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref } from 'vue'
import AppNavbar from '@/components/AppNavbar.vue'
import SideBar from '@/components/SideBar.vue'

const isLoggedIn = ref(localStorage.getItem('isLoggedIn') === 'true')

const merchs = ref([
  {
    id: 1,
    title: '星际远征定制手办',
    img: 'https://images.unsplash.com/photo-1519125323398-675f0ddb6308?auto=format&fit=crop&w=400&q=80',
    type: '手办',
    price: 199,
    inStock: true,
  },
  {
    id: 2,
    title: '机械迷城主题T恤',
    img: 'https://images.unsplash.com/photo-1508766206392-8bd5cf550d1d?auto=format&fit=crop&w=400&q=80',
    type: '服饰',
    price: 89,
    inStock: false,
  },
  {
    id: 3,
    title: '极速竞速鼠标垫',
    img: 'https://images.unsplash.com/photo-1464983953574-0892a716854b?auto=format&fit=crop&w=400&q=80',
    type: '外设',
    price: 59,
    inStock: true,
  },
  {
    id: 4,
    title: '魔法世界钥匙扣',
    img: 'https://images.unsplash.com/photo-1511512578047-dfb367046420?auto=format&fit=crop&w=400&q=80',
    type: '饰品',
    price: 29,
    inStock: true,
  },
])
</script>

<style scoped>
.game-merch-layout {
  display: flex;
  flex-direction: row;
  width: 100vw;
  min-height: 100vh;
  background: linear-gradient(135deg, #181a20 60%, #232946 100%);
  justify-content: center;
}
.game-merch-view {
  flex: 1;
  margin-left: 180px;
  padding: 56px 0 32px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  width: 100%;
  box-sizing: border-box;
  color: #fff;
  background: linear-gradient(135deg, #181a20 60%, #232946 100%);
}
.game-merch-view h2 {
  color: #a3b8d8;
  font-size: 2.4rem;
  margin-bottom: 36px;
  letter-spacing: 2px;
  text-shadow: 0 2px 18px #3a4a6a44, 0 0 2px #232946;
  font-weight: 700;
  transition: color 0.3s;
}
.merch-list {
  display: flex;
  flex-wrap: wrap;
  gap: 40px 48px;
  justify-content: center;
  width: 90vw;
  max-width: 1400px;
}
.merch-card {
  background: linear-gradient(135deg, rgba(35,41,70,0.97) 60%, rgba(78,140,255,0.10) 100%);
  border-radius: 22px;
  box-shadow: 0 6px 32px 0 #4e8cff22, 0 0 0 2px #232946;
  overflow: hidden;
  width: 320px;
  min-height: 420px;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: transform 0.3s, box-shadow 0.3s, border 0.3s;
  cursor: pointer;
  border: 2px solid transparent;
  position: relative;
  backdrop-filter: blur(1.5px);
  color: #b0b3b8;
}
.merch-card:hover {
  transform: translateY(-10px) scale(1.035);
  box-shadow: 0 12px 48px 0 #4e8cff55, 0 0 0 2.5px #4e8cff;
  border: 2px solid #4e8cff;
}
.merch-cover {
  width: 100%;
  height: 180px;
  object-fit: cover;
  display: block;
  filter: brightness(0.95) contrast(1.08);
  border-bottom: 1.5px solid #232946;
}
.merch-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 28px 18px 18px 18px;
}
.merch-info h3 {
  color: #fff !important;
  font-size: 1.25rem;
  margin-bottom: 16px;
  text-align: center;
  font-weight: 600;
  letter-spacing: 1px;
  text-shadow: 0 2px 12px #4e8cff33;
}
.merch-meta {
  display: flex;
  gap: 18px;
  margin-bottom: 18px;
  align-items: center;
  justify-content: center;
}
.merch-type {
  color: #fff !important;
  font-size: 1.05rem;
  background: #232946;
  border-radius: 10px;
  padding: 4px 14px;
  font-weight: 500;
  box-shadow: 0 1px 6px #4e8cff22;
}
.merch-price {
  color: #fff !important;
  font-size: 1.08rem;
  font-weight: bold;
  background: #232946;
  border-radius: 10px;
  padding: 4px 14px;
  box-shadow: 0 1px 6px #4e8cff22;
}
.merch-status {
  color: #fff !important;
  font-size: 1.05rem;
  border-radius: 10px;
  padding: 4px 14px;
  font-weight: 500;
  box-shadow: 0 1px 6px #4e8cff22;
  background: #232946;
  transition: background 0.2s, color 0.2s;
}
.merch-status.in-stock {
  background: #4e8cff;
  color: #fff;
}
.merch-status.out-stock {
  background: #444a5a;
  color: #bbb;
}
.merch-actions {
  display: flex;
  gap: 14px;
  justify-content: center;
  margin-top: 10px;
}
.buy-btn {
  background: linear-gradient(90deg, #4e8cff 0%, #6ed0ff 100%);
  color: #232946;
  border: none;
  border-radius: 8px;
  padding: 8px 22px;
  font-size: 1.05rem;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 1px 6px #4e8cff22;
  transition: background 0.2s, color 0.2s, box-shadow 0.2s, transform 0.2s;
}
.buy-btn:hover {
  background: linear-gradient(90deg, #6ed0ff 0%, #4e8cff 100%);
  color: #fff;
  box-shadow: 0 4px 16px #4e8cff55;
  transform: scale(1.05);
}
.detail-btn {
  background: #232946;
  color: #7fa7d6;
  border: none;
  border-radius: 8px;
  padding: 8px 18px;
  font-size: 1.05rem;
  font-weight: 500;
  cursor: pointer;
  box-shadow: 0 1px 6px #4e8cff22;
  transition: background 0.2s, color 0.2s, box-shadow 0.2s, transform 0.2s;
}
.detail-btn:hover {
  background: #4e8cff;
  color: #fff;
  box-shadow: 0 4px 16px #4e8cff55;
  transform: scale(1.05);
}
@media (max-width: 900px) {
  .game-merch-view {
    padding: 24px 0 16px 0;
  }
  .merch-list {
    width: 98vw;
    max-width: 100vw;
    gap: 24px 8px;
  }
  .merch-card {
    width: 98vw;
    min-width: 180px;
    max-width: 100vw;
  }
}
.merch-list-header span {
  color: #fff !important;
}
</style> 